package com.szalay.desktopsearch.ui;

import java.util.ArrayList;
import java.util.List;
import javax.swing.Action;
import javax.swing.JPopupMenu;
import javax.swing.JToolBar;
import org.apache.solr.common.SolrDocument;

/**
 * Utility to create the toolbar for the details window.
 * 
 * @author szalay
 */
final class DetailsToolBar {
    /**
     * Noop constructor.
     */
    private DetailsToolBar() {
        //Never called...
    }
    
    /**
     * Get all available actions for documents.
     * @param document
     * @param menuParent
     * @return 
     */
    static List<Action> getDocumentActions(final SolrDocument document, final JPopupMenu menuParent) {
        final List<Action> actions = new ArrayList<Action>(3);
        actions.add(new OpenItemAction(document, menuParent));
        actions.add(new EditItemAction(document, menuParent));
        actions.add(new PrintItemAction(document, menuParent));
        return actions;
    }
    
    /**
     * Creates the toolbar for the details window.
     * @return 
     */
    static JToolBar getDetailWindowToolBar(final SolrDocument document, final JPopupMenu menuParent) {
        final JToolBar toolBar = new JToolBar();
        for (final Action a : getDocumentActions(document, menuParent)) {
            toolBar.add(a);
        }
        return toolBar;
    }
}
